import { defHttp } from '/@/utils/http/axios';
import {WebsiteClassificationTreeModel,WebsiteClassificationModel, WebsiteClassificationTableRecordModel} from "/@/api/model/websiteClassificationModel";
import {ErrorMessageMode} from "/#/axios";

enum Api {
  GET_CLASSIFICATION_TREE = '/jxxhWebsite/websiteClassification/getClassificationTree',
  WEBSITECLASSIFICATION_PAGE = '/jxxhWebsite/websiteClassification/getClassificationVosPage',
  GET_WEBSITECLASSIFICATIONVO_BY_ID = '/jxxhWebsite/websiteClassification/',
  WEBSITECLASSIFICATIONVO_SAVE = '/jxxhWebsite/websiteClassification/save',
  WEBSITECLASSIFICATIONVO_UPDATE = '/jxxhWebsite/websiteClassification/updateById',
  WEBSITECLASSIFICATIONVO_REMOVE = '/jxxhWebsite/websiteClassification/logicalRemoveById/',
}

/**
 * @description: Get sample list value
 */

export function getClassificationTreeApi() {
  return defHttp.get<WebsiteClassificationTreeModel>(
    { url: Api.GET_CLASSIFICATION_TREE },
    { errorMessageMode: 'message' },
  );
}

/**
 * @description: Get sample list value
 */

export const websiteClassificationListApi = (params: Object) =>
  defHttp.get<WebsiteClassificationTableRecordModel>(
    {url: Api.WEBSITECLASSIFICATION_PAGE,params },
    { errorMessageMode: 'message' }
  );

export const getWebsiteClassificationVoByIdApi = (id) =>
  defHttp.get<WebsiteClassificationModel>(
    {url: Api.GET_WEBSITECLASSIFICATIONVO_BY_ID+id },
    { errorMessageMode: 'message' }
  );

export function websiteClassificationSaveApi(params: WebsiteClassificationModel, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<WebsiteClassificationModel>(
    {
      url: Api.WEBSITECLASSIFICATIONVO_SAVE,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
export function websiteClassificationUpdateApi(params: WebsiteClassificationModel, mode: ErrorMessageMode = 'modal') {
  return defHttp.put<WebsiteClassificationModel>(
    {
      url: Api.WEBSITECLASSIFICATIONVO_UPDATE,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
export const logicalRemoveById = (id) =>
  defHttp.delete<WebsiteClassificationModel>(
    {url: Api.WEBSITECLASSIFICATIONVO_REMOVE+id },
    { errorMessageMode: 'message' }
  );
